﻿using System;
using System.Diagnostics;
using System.Windows;
using nRoute.Components.Composition;

namespace nRoute.ApplicationServices
{
    public partial class nRouteApplicationService
        : IApplicationService
    {

#region IApplicationService related

        public void StartService(ApplicationServiceContext context)
        {
            if (!_resourceCatalog.ValueSet)
            {
                var _catalog = new ResourceCatalog();
                _resourceCatalog.Value = _catalog;
                _catalog.Initialize(OnInitialized);
            }
            else
            {
                this.OnInitialized();
            }
        }

        public void StopService()
        {
            var _diposable = _resourceCatalog.Value as IDisposable;
            if (_diposable != null) _diposable.Dispose();
        }

#endregion

    }
}
